﻿using System.Collections.Generic;

namespace Common.Models
{
    /// <summary>
    /// 查询过滤器
    /// </summary>
    public class QueryFilter
    {
        /// <summary>
        /// 页码，默认1
        /// </summary>
        public int PageIndex { get; set; } = 1;

        /// <summary>
        /// 每页记录数，默认20
        /// </summary>
        public int PageSize { get; set; } = 20;

        /// <summary>
        /// 排序字段，默认Id
        /// </summary>
        public string OrderBy { get; set; } = "Id";

        /// <summary>
        /// 是否升序，默认true
        /// </summary>
        public bool IsAscending { get; set; } = true;

        /// <summary>
        /// 过滤条件列表
        /// </summary>
        public List<FilterCondition> Conditions { get; set; } = new List<FilterCondition>();
    }

    /// <summary>
    /// 过滤条件
    /// </summary>
    public class FilterCondition
    {
        /// <summary>
        /// 字段名
        /// </summary>
        public string Field { get; set; }

        /// <summary>
        /// 操作符，如：=、>、<、like等
        /// </summary>
        public string Operator { get; set; }

        /// <summary>
        /// 值
        /// </summary>
        public object Value { get; set; }
    }
}